//index.js
//获取应用实例
var app = getApp()
Page({
    data: {
        ordersLength: 0,

        importordersLength: 0,
        allordersLength: 0,
        tabArr: {
            curHdIndex: 0,
            curBdIndex: 0
        },
        
        currentTab: 0,
        searchkey:'',
        credittype:'credit2',
        targetmemberid:'',
        tabArray: ["已审订单", "未审订单", "订单汇总"],

    },

    onLoad: function (options) {
        if (typeof options != "undefined" && typeof options.targetmemberid != "undefined") {
            console.log(options.targetmemberid);
            this.setData({"targetmemberid":options.targetmemberid});
        }else{
            this.setData({ "targetmemberid": "" });
        }
        this.getMyLog();
    },
    getMyLog: function () {
        var $that = this;
        var m_type = $that.data.currentTab == 0 ? 1 : 0;
        console.log("函数执行");
        var memberinfo = wx.getStorageSync("memberinfo");
        app.util.request({
            url: 'entry/wxapp/PartnerLog',
            data: {
                "m": 'nets_haojk',
                "memberid": memberinfo.memberid,
                "targetmemberid": $that.data.targetmemberid,
                "page": 1,
                "keyword": $that.data.searchkey,
                "type": '',
                "credittype": $that.data.credittype
            },
            method: 'post',
            success: function (response) {

                $that.setData({ "memberlogs": response.data.data });
            }
        })
    },
    //事件处理函数
    tabFun: function (e) {
        var $that = this;
        //获取触发事件组件的dataset属性  
        var _datasetId = e.target.dataset.id;
        var credittype = _datasetId==0?"credit2":"credit1";
        
        var _obj = {};
        _obj.curHdIndex = _datasetId;
        _obj.curBdIndex = _datasetId;
        this.setData({
            tabArr: _obj,
            currentTab: _datasetId,
            credittype: credittype
        });


        this.getMyLog();
    },
    searchkey: function () {
        this.getMyLog();
    },
    bindKeyInput: function (e) {

        var value = e.detail.value;
        this.setData({ "searchkey": value });

    },
    //事件处理函数
    bindViewTap: function () {
        wx.navigateTo({
            url: '../detail/index'
        })
    },

    //底部列表条转  
    skipToOrder: function () {
        wx.navigateTo({
            url: '../partnerOrder/index',
        })
    },
    skipToIndex: function () {
        wx.navigateTo({
            url: '../partnerIndex/index',
        })
    },
    skipToMember: function () {
        wx.navigateTo({
            url: '../partnerMember/index',
        })
    },
    skipToFinance: function () {
        wx.navigateTo({
            url: '../partnerFinance/index',
        })
    } 
})
